package org.dream.service;

import java.util.ArrayList;
import java.util.List;

/**
 * 
 * @author qiuriyuchen E-mail:panpan_001@126.com
 */
public class Calculate {

	/**
	 * 均线计算
	 * 
	 * @param list
	 * @param day
	 * @return
	 */
	public static List<Double> ma(List<Double> list, int day) {
		List<Double> maList = new ArrayList<Double>();
		for (int i = 0; i < list.size(); i++) {
			double a = 0.0;
			for (int j = 0; j < day && i - j >= 0; j++) {
				a += list.get(i - j);
			}
			maList.add(a / day);
		}
		return maList;
	}
	

}
